package com.xdhl.fu.member.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.xdhl.fu.common.core.web.domain.AjaxResult;
import com.xdhl.fu.member.domain.City;
import com.xdhl.fu.member.service.ICityService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 城市控制器
 *
 * @author 朱力维
 * @time 2022/7/2 16:11
 */
@RestController
@RequestMapping("/city")
public class CityController {
    @Resource
    private ICityService cityService;

    /**
     * 根据省份Id获取城市列表
     *
     * @return 指定省份的城市列表
     */
    @GetMapping("/{cityUpId}")
    public AjaxResult getCityByProvinceId(@PathVariable String cityUpId) {
        LambdaQueryWrapper<City> condition = new LambdaQueryWrapper();
        condition.eq(City::getCityUpId, cityUpId);
        List<City> list = cityService.list(condition);
        return AjaxResult.success(list);
    }
}
